<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<base href="<%=basePath%>">
<!--忘记密码的页面-->
<link rel="stylesheet" type="text/css" href="css/forgetPassword.css"/>
<script type="text/javascript">
	//用户注册验证
function forgetPasswordCheck(){
	var username=document.getElementById("username").value;
	var password1=document.getElementById("password1").value;
	var password2=document.getElementById("password2").value;
	var name=document.getElementById("name").value;
	var email=document.getElementById("email").value;
	var tel=document.getElementById("tel").value;
	var code=document.getElementById("code").value;
	
	var isUsername=/([0-9]|[a-z]|[A-Z]){6,16}/;
	var isPassword=/.{6,20}/;
	var isName=/.{2,40}/;
	var isEmail=/.{5,60}/;
	var isTel=/[0-9]{11}/;
	var isCode=/([0-9]|[a-z]|[A-Z]){4}/;
	
	if(!isCode.test(code)){
		window.alert("验证码不正确");
		return false;
	}
	if(!isUsername.test(username)){
		window.alert("用户名长度不正确,或者输入了非字母、数字");
		return false;
	}
	if(!isPassword.test(password1)){
		window.alert("密码长度不正确，或输入了不允许的字符");
		return false;
	}
	if(password1!=password2){
		window.alert("两次输入的密码不一致");
		return false;
	}
	if(!isName.test(name)){
		window.alert("姓名不符合要求");
		return false;
	}
	if(!isEmail.test(email)){
		window.alert("email格式不正确");
		return false;
	}
	if(!isTel.test(tel)){
		window.alert("电话长度必须是11位");
		return false;
	}
}
</script>
<div class="password">
	<h1>忘记密码</h1>
	<form action="forgetPassword" method="post" onsubmit="return forgetPasswordCheck()">
		<table align="center">
			<tr><td>账号：</td><td><input type="text" id="username" value="" name="user.username"/><br /></td></tr>
			<tr><td>姓名：</td><td><input type="text" id="name" value="" name="user.name"/><br /></td></tr>
			<tr><td>邮箱：</td><td><input type="text" id="email" value="" name="user.email"/><br /></td></tr>
			<tr><td>电话：</td><td><input type="text" id="tel" value="" name="user.tel"/><br /></td></tr>
			<tr><td>新密码：</td><td><input type="password" id="password1" value="" name="user.password"/><br /></td></tr>
			<tr><td>再输一遍：</td><td><input type="password" id="password2" value="" name=""/><br /></td></tr>
			<tr><td>验证码：</td><td><input name="code" type="text" id="code" size="6"><img src="code?id=${request.Coderandom}" onclick="this.src='code?id='+Math.random()" /></td></tr>
			<tr align="center"><td><input type="submit" value="提交"/></td><td><input type="reset" value="重置"/></td></tr>
		</table>		
	</form>
</div>